package com.cskaoyan.controller;

import com.cskaoyan.bean.*;
import com.cskaoyan.bean.basebean.BaseRespVo;
import com.cskaoyan.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @description: ${description}
 * @author: cuicui
 **/
@RestController
@RequestMapping("wx/cart")
public class CartController {

    @Autowired
    CartService cartService;

    @PostMapping("checked")
    public BaseRespVo CartChecked(@RequestBody CartCheckedBO bo) {
        CartCheckedVO vo = cartService.checked(bo);
        return BaseRespVo.ok(vo,"成功");
    }


    @PostMapping("delete")
    public BaseRespVo CartDelete(@RequestBody Map map){
        List<Integer> productIds = (ArrayList)map.get("productIds");
        CartCheckedVO vo = cartService.delete(productIds);
        return BaseRespVo.ok(vo,"成功");

    }
    @PostMapping("fastadd")
    public BaseRespVo CartFastadd(@RequestBody FastaddBO bo){
        Integer cartID = cartService.fastadd(bo);
        return BaseRespVo.ok(cartID,"成功");
    }

    @GetMapping("checkout")
    public BaseRespVo CartCheckoutGet(CartCheckoutBO bo) {
        CartCheckoutVO vo = cartService.checkout(bo);
        return BaseRespVo.ok(vo,"成功");
    }
}
